package com.shen;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Author:shen
 * CreateDate:2020/6/1.
 * Function:
 */
public class demo02 {
    public static void main(String[] args) {
        for (int i=1900;i<=2020;i++){
           if ( test(i)){
               System.out.println(i+"年是闰年");
           }else{
               System.out.println(i+"年不是闰年");
           }
        }

    }
    public static boolean test(int year){
        boolean flag=false;
        Calendar calendar=Calendar.getInstance();
        calendar.set(year,2,1);//设置年份
        //获得该年的二月天数
        calendar.add(Calendar.DAY_OF_MONTH,-1);
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        if(day==28){
            flag=false;
        }else{
            flag=true;
        }
        return flag;
    }
}
